package com.ruoyi.find.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.find.domain.PropertyComment;
import com.ruoyi.find.service.IPropertyCommentService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 楼盘点评Controller
 * 
 * @author gjq
 * @date 2025-09-18
 */
@RestController
@RequestMapping("/comment")
public class PropertyCommentController extends BaseController
{
    @Autowired
    private IPropertyCommentService propertyCommentService;

    /**
     * 查询楼盘点评列表
     */
    @RequiresPermissions("find:comment:list")
    @GetMapping("/list")
    public TableDataInfo list(PropertyComment propertyComment)
    {
        startPage();
        List<PropertyComment> list = propertyCommentService.selectPropertyCommentList(propertyComment);
        return getDataTable(list);
    }

    /**
     * 导出楼盘点评列表
     */
    @RequiresPermissions("find:comment:export")
    @Log(title = "楼盘点评", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PropertyComment propertyComment)
    {
        List<PropertyComment> list = propertyCommentService.selectPropertyCommentList(propertyComment);
        ExcelUtil<PropertyComment> util = new ExcelUtil<PropertyComment>(PropertyComment.class);
        util.exportExcel(response, list, "楼盘点评数据");
    }

    /**
     * 获取楼盘点评详细信息
     */
    @RequiresPermissions("find:comment:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(propertyCommentService.selectPropertyCommentById(id));
    }

    /**
     * 新增楼盘点评
     */
    @RequiresPermissions("find:comment:add")
    @Log(title = "楼盘点评", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PropertyComment propertyComment)
    {
        return toAjax(propertyCommentService.insertPropertyComment(propertyComment));
    }

    /**
     * 修改楼盘点评
     */
    @RequiresPermissions("find:comment:edit")
    @Log(title = "楼盘点评", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PropertyComment propertyComment)
    {
        return toAjax(propertyCommentService.updatePropertyComment(propertyComment));
    }

    /**
     * 删除楼盘点评
     */
    @RequiresPermissions("find:comment:remove")
    @Log(title = "楼盘点评", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(propertyCommentService.deletePropertyCommentByIds(ids));
    }
}
